@extends('frontend/layouts/flaty_to_bootstrap')

@section('content.title')
<h1><i class="icon-list"></i> Purchase Car List</h1>
@stop

@section('content.breadcrumb.inner')
<li><a href="{{ route('home') }}"><i class="icon-home"></i> Dashboard</a><span class="divider"><i class="icon-angle-right"></i></span></li>
<li class="active">Purchase Car list</li>
@stop

@section('content.main')

<p>{{ link_to_route('car_balance.purchase_car.create', 'Add new Purchase Car', null, array('class' => 'btn btn-info')) }}</p>


{{-- FILTER --}}
<div class="row-fluid">
    <div class="span12">
        <div class="box box-gray">
            <div class="box-title">
                <h3><i class="icon-table"></i> Filter option</h3>
                <div class="box-tool">
                    <a data-action="collapse" href="#"><i class="icon-chevron-up"></i></a>
                </div>
            </div>
            <div class="box-content">
                <form action="{{ route('car_balance.main.car_list_filter') }}" class="form-horizontal" method="post">
                    <div class="row">
                        <div class="span12">
                  <div class="span6">
                    <div class="control-group">
                        <label class="control-label">Purchase car id</label>
                        <div class="controls">
                            <span >
                                <input id="purchase-car-id" type="text" name="purchase_car_id" value="{{ $filters['purchase_car_id'] ? $filters['purchase_car_id'] : '' }}"/>
                            </span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">Purchase date</label>
                        <div class="controls">
                            <span >
                                <i class="icon-calendar"></i>
                                &nbsp;
                                <input id="form-date-range" type="text" name="purchase_date" id="daterange" value="{{ count($filters['purchase_date']) > 1 ? $filters['purchase_date'][0] .' to '.$filters['purchase_date'][1] : '' }}"/>
                            </span>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">Hudaldan avagch</label>
                        <div class="controls">
                            {{ Form::select('customer_id', $customer_list, $filters['customer_id']) }}
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">Car auction</label>
                        <div class="controls">
                            {{ Form::select('car_auction_id', $car_auction_list, $filters['car_auction_id']) }}
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">Service company</label>
                        <div class="controls">
                            {{ Form::select('service_company_id', $service_company_list, $filters['service_company_id']) }}
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">Price</label>
                        <div class="controls">
                            FROM: <input type="text" class="input-small" name="price_from" />
                            TO: <input type="text" class="input-small" name="price_to" />
                        </div>
                    </div>
                  </div>
                  <div class="span6">
                      <div class="control-group">
                          <label class="control-label">Car Maker</label>
                          <div class="controls">
                              {{ Form::select('car_maker_list', $car_maker_list, '', array('data-placeholder' => 'Car maker', 'class' => 'chosen span6', 'multiple' => 'multiple', 'name' => 'makers[]')) }}
                          </div>
                      </div>

                      <div class="control-group">
                          <label class="control-label">Chassis number</label>
                          <div class="controls">
                              <input type="text" name="chassis_number" />
                          </div>
                      </div>

                      <div class="control-group">
                          <label class="control-label">Container id</label>
                          <div class="controls">
                              <input type="text" name="container_id" />
                          </div>
                      </div>

                  </div>

                        </div>
                    </div>
                    {{ Form::token() }}
                    <input class="btn btn-primary" type="submit" value="apply filter"/>
                </form>
            </div>
        </div>
    </div>
</div>

@if ($cars->count())

<div class="row-fluid">
    <div class="span12">
        <div class="box box-blue">
            <div class="box-title">
                <h3><i class="icon-table"></i> Purchase Car list</h3>
                <div class="box-tool">
                    <a data-action="collapse" href="#"><i class="icon-chevron-up"></i></a>
                </div>
            </div>
            <div class="box-content">
<table class="table table-striped table-hover fill-head">
    <thead>
    <tr>
        <th>#</th>
        <th>Purchase date</th>
        <th>Car maker</th>
        <th>Car type</th>
        <th>Price</th>
        <th>Consumption tax</th>
        <th>Recycle fee</th>
        <th>Car certification</th>
        <th>Auction commission</th>
        <th>Transport fee japan</th>
        <th>Transport fee japan fixed</th>
        <th>NMH Commission</th>
        <th>Service company</th>
        <th>Car auction</th>
        <th>Hudaldan avagch</th>
        <th>Vanning company</th>
        <th style="width: 70px">Action</th>
    </tr>
    </thead>
    <tbody>
    @foreach($cars as $car)
    <tr>
        <td>{{ link_to_route('nd.car_balance.main.car_show', $car->id, $car->id, array()) }}</td>
        <td>{{ $car->purchase_date }}</td>
        <td>{{ $car->car_maker }}</td>
        <td>{{ $car->car_type }}</td>
        <td>{{ $car->price; }}</td>
        <td>{{ $car->consumption_tax; }}</td>
        <td>{{ $car->recycle_fee; }}</td>
        <td>{{ $car->car_certification; }}</td>
        <td>{{ $car->auction_comission; }}</td>
        <td>{{ $car->transport_fee_japan }}</td>
        <td>{{ $car->transport_fee_japan_fxd; }}</td>
        <td>{{ $car->nmh_commision }}</td>
        <td>{{ $car->serviceCompany ? link_to_route('car_balance.service_company.show', $car->serviceCompany->name, $car->serviceCompany->id, array()) : 'NULL' }}</td>
        <td>{{ $car->carAuction ? link_to_route('car_balance.car_auction.show', $car->carAuction->name, $car->carAuction->id, array()) : 'NULL' }}</td>
        <td>{{ $car->customer ? link_to_route('car_balance.customer.show', $car->customer->name, $car->customer->id, array()) : 'NULL' }}</td>
        <td>{{ $car->vanningCompany ? link_to_route('car_balance.vanning_company_branch.show', $car->vanningCompany->name, $car->vanningCompany->id, array()) : 'NULL' }}</td>
        <td>
            <a class="btn btn-primary btn-small" href="#" title="Edit"><i class="icon-edit"></i></a>
            <a class="btn btn-danger btn-small" href="#" title="Delete"><i class="icon-trash"></i></a>
        </td>
    </tr>
    @endforeach
    </tbody>
</table>
            </div>
        </div>
    </div>
</div>


@else
    There are no purchase_cars
@endif

@stop


@section('stylesheets.more')
<link rel="stylesheet" type="text/css" href={{ asset('assets/chosen-bootstrap/chosen.min.css') }} />
<link rel="stylesheet" type="text/css" href={{ asset('assets/bootstrap-daterangepicker/daterangepicker.css') }} />
@stop

@section('javascripts.more')
<!--page specific plugin scripts-->
<script type="text/javascript" src={{ asset('assets/chosen-bootstrap/chosen.jquery.min.js') }}></script>
<script type="text/javascript" src={{ asset('assets/bootstrap-daterangepicker/date.js') }} ></script>
<script type="text/javascript" src={{ asset('assets/bootstrap-daterangepicker/daterangepicker.js') }}></script>
@stop